package com.libweb.servlet;

import java.io.IOException;

import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.libweb.model.dao.RentDao;
import com.libweb.model.dto.Rent;
import com.libweb.model.dto.Book;
import com.libweb.model.dao.BookDao;

@WebServlet("/rent/rentregister.action")
public class RentRegisterServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;

	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		int bookNo = Integer.parseInt(request.getParameter("bookno"));
		String memberId = request.getParameter("memberid");
		
		Rent rent = new Rent();
		rent.setBookNo(bookNo);
		rent.setMemberId(memberId);
		
		RentDao dao = new RentDao();
		dao.insertRent(rent);
		
		response.sendRedirect("/libweb/book/list.action");
		
	}

	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		
		request.setCharacterEncoding("utf-8");
		
		doGet(request, response);
		
	}

}
